#ifndef PIMAGE_H
#define PIMAGE_H

#include <QtGui/QMainWindow>
#include <QPicture>
#include <QPainter>
#include <QToolButton>
#include <QFileDialog>
#include <QLabel>
#include <iostream>
#include <QObject>

#include "ui_pimage.h"
#include "ui_newProject.h"
#include "ui_closeApplication.h"
#include "ui_APropos.h"

#include "GraphicsArea/drawingarea.h"
#include "GraphicsArea/drawingarea.h"

#include "Filter/filter.h"
#include "Filter/gaussfilter.h"
#include "Filter/grayscalefilter.h"
#include "Filter/medianfilter.h"
#include "Filter/matrixfilter.h"
#include "Filter/negativefilter.h"
#include "Filter/bruitpoivreetsel.h"
#include "Filter/sobelfilter.h"
#include "Filter/upoutline.h"

#include "DockWidget/DockWidgetTools/colorview.h"
#include "DockWidget/DockWidgetCalques/calque.h"
#include "DockWidget/DockWidgetColors/colors.h"
#include "DockWidget/DockWidgetTools/ui_tools.h"

#include "Redimension/redimension.h"

#include "Histogram/histogramme.h"


namespace Ui{
    class PImageClass;
}

using namespace UiTools;
using namespace std;

class PImage : public QMainWindow{
    Q_OBJECT

public:
    //***************************************************************************** Constructor
    PImage(QWidget *parent = 0);
    //*****************************************************************************  Destructor
    ~PImage();
     //***************************************************************************** Gestion of Zoom
    void afficheZoom(DrawingArea *draw);
    //*****************************************************************************  Dock Colors
    Colors *getUiColors();
    //*****************************************************************************  Drawing
    DrawingArea* getCurrentDrawing();
    //*****************************************************************************  Dock Calque
    void updateCalque(DrawingArea* drawing = NULL);

    Ui::PImageClass* ui;

private:
     //***************************************************************************** Enable the button
    void enableButtonMenu();
    //*****************************************************************************  Dock Tools
    void createTools();
    //*****************************************************************************  Dock Calque
    void createCalque();
    //*****************************************************************************  Dock Colors
    void createDockColors();

    //*****************************************************************************  Variables
    QTabWidget* tabDrawingArea;

    QWidget* contentDockWidgetTools;
    QWidget* contentDockWidgetInfoTool;
    QWidget* contentDockWidgetColors;

    Ui_NewProjectNS::NewProject *ui_NewProject;
    Ui_CloseApplicationNS::CloseApplication *ui_CloseApplication;
    Ui_AProposNS::APropos *ui_APropos;
    Colors* uiColors;
    UiTools::ToolsClass* uiTools;

    Calque* calque;

    Histogramme* histogram;

    Redimension* redimension;

    BruitPoivreEtSel* bruitPoivreEtSel;

    int newProjectCount;

    Layer* layerCopy;

public slots:
    //***************************************************************************** Gestion of Zoom
    void zoomPlus();
    void zoomMoin();
    //***************************************************************************** Menu Fichier
    void newProject();
    void newProjectValidate();
    void open();
    void closeDrawing();
    void closeDrawing(int);
    void save();
    void saveAs();
    void quit();
    void quitConfirme();
    void closeEvent(QCloseEvent * event);
    void saveAsClose();
    //***************************************************************************** MEnu Edition
    void copy();
    void paste();
    void selectAll();
   //****************************************************************************  Menu Image
    void redimensionner();
    //******************************* Miroir
    void MiroirHorizontal();
    void MiroirVertical();
    //******************************* Rotation
    void rotation90AntiHoraire();
    void rotation90Horaire();
    //****************************************************************************  Menu Histogramme
    void showHistogram();
    void showHistEgalize();
    void showHistSpread();
    void showHistShift();
    void showHistBin();
    //**************************************************************************** Menu Filtre
    void median();
    void attenuate();
    void desaturate();
    void negative();
    void convolution();
    void sobel();
    void upOutline();
    void noise();
    //**************************************************************************** Menu Affichage
     void toolsWidgetShow();
     void CalquesShow();
     void ColorShow();
     void MenuAffichageUpdate();
    //************************************************************************** Menu Layers
    void addNewLayer();
    void removeLayer();
    void selectTheLowerLayer();
    void selectTheUpperlayer();
    void selectTheLowestLayer();
    void selectTheUppestLayer();
    void takeDownTheLayer();
    void takeUpTheLayer();
    void fusionVisibleLayersUnion();
    void fusionVisibleLayersFitImage();
    void fusionVisibleLayersIntersection();
    //*****************************************************************************  Menu Aide
    void aPropos();
    //*****************************************************************************  Tools
    void croppedMode();
    void moveMode();
    void moveModeSelection();
    void takeColorMode();
    void selectionRectMode();
    void cleverSelectionMode();
    void pencilMode();
    //*****************************************************************************  Gestion of tabs
    void changementTab();
};

#endif // PIMAGE_H
